package bairui.international.service.config;

import org.hibernate.dialect.MySQL5InnoDBDialect;
import org.hibernate.dialect.function.SQLFunctionTemplate;
import org.hibernate.type.StandardBasicTypes;

public class MySQLLocalDialect extends MySQL5InnoDBDialect {
	public MySQLLocalDialect(){   
        registerFunction("add_years", new SQLFunctionTemplate(StandardBasicTypes.DATE, "date_add(?1, interval ?2 year)"));
        registerFunction("add_months", new SQLFunctionTemplate(StandardBasicTypes.DATE, "date_add(?1, interval ?2 month)"));
        registerFunction("add_weeks", new SQLFunctionTemplate(StandardBasicTypes.DATE, "date_add(?1, interval ?2 week)"));
        registerFunction("add_days", new SQLFunctionTemplate(StandardBasicTypes.DATE, "date_add(?1, interval ?2 day)"));
    }
}